<?php

 
 Zend_Loader::loadClass("BaseDBRows");
 Zend_Loader::loadClass("OrganismGroup");
 class OrganismGroups extends BaseDBRows
 {
 	protected function setUp()
 	{
 		$this->_tableName = OrganismGroup::_tablename;
 	}	
	
	public function getOrganismGroupsByOrgId($orgId)
	{
		Zend_Loader::loadClass("Organism");
		Zend_Loader::loadClass("OrganizationOrganism");
		Zend_Loader::loadClass("QueryCreator");
		
		$query = new QueryCreator();
		$query->addSelect("distinct og.organism_group_id, og.organism_group");
		$query->addFrom(OrganizationOrganism::_tablename . " as oo ");
		$query->addJoin("," . Organism::_tablename . " as o ");
		$query->addJoin("," . $this->_tableName . " as og ");	
		$query->addWhere("oo.organism_id = o.organism_id");
		$query->addWhere("o.organism_group_id = og.organism_group_id");
		$query->addWhere(" oo.org_id = " . $orgId);
		$query->addOrderBy("og.organism_group");
		
		//die($query->createSQL());
		$db = DBCon::instance();
		$result = $db->executeQuery($query->createSQL());
		return $result;
	}
	
 }
?>